package crp.services.api.graphql.models;

import crp.core.user.domain.models.UserEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.eclipse.microprofile.graphql.Id;
import org.eclipse.microprofile.graphql.Ignore;
import org.eclipse.microprofile.graphql.Type;

import javax.validation.constraints.NotNull;

@Type("User")
@Builder
@Getter
@AllArgsConstructor
public class UserPayload {
    @Id
    @NotNull
    private final String id;
    @NotNull
    private final String name;
    @Ignore
    private final String facultyId;
    @Ignore
    private final String studentId;

    public static UserPayload of(UserEntity entity) {
        return UserPayload.builder()
                .id(entity.getId())
                .name(entity.getName())
                .facultyId(entity.getFacultyId())
                .studentId(entity.getStudentId())
                .build();
    }
}
